    var myChart = echarts.init(document.getElementById('echarts'));

    var option = {
        tooltip: {
            trigger: 'item'
        },
        legend: {
            top: '5%',
            left: 'center'
        },
        color: ['#5470c6', '#9fe080'],
        series: [{
            name: '用户来源',
            type: 'pie',
            radius: ['40%', '70%'],
            avoidLabelOverlap: false,
            label: {
                show: false,
                position: 'center'
            },
            emphasis: {
                label: {
                    show: true,
                    fontSize: '40',
                    fontWeight: 'bold'
                }
            },
            labelLine: {
                show: false
            },
            data: [
                { value: '11', name: '女性' },
                { value: '22', name: '男性' },
            ]
        }]
    };
    myChart.setOption(option);



    var myChart2 = echarts.init(document.getElementById('art_class'));

    var option2 = {
        xAxis: {
            type: 'category',
            data: []
        },
        yAxis: {
            type: 'value'
        },
        title: {
            text: '各分类文章发布数量',
            left: 'center',
            top: '20',
            textColor: '#5c7bd9',
        },

        barWidth: 60,
        color: ['#5c7bd9'],
        series: [{
            data: [],
            type: 'bar',
            showBackground: true,
            backgroundStyle: {
                color: 'rgba(180, 180, 180, 0.2)'
            }
        }]
    };

    myChart2.setOption(option2);
    //获取主页主页统计信息
    getPageinfo()

    function getPageinfo() {
        $.ajax({
            method: 'GET',
            url: '/index/baseInfo',
            success: function(res) {
                if (res.errno !== 0) {
                    return layer.msg('获取统计信息失败', { icon: 5 })
                }
                //统计数据渲染
                infoSum(res.data);

                //定义模板引擎传递服务器响应的数据
                //新用户统计
                var new_user_str = template('new_user_tpl', res.data)
                $('#new_user').html(new_user_str)
                    //文章排行
                var art_list_str = template('art_list_tpl', res.data)
                $('#art_top').html(art_list_str)


                //饼图
                option.series[0].data[0].value = res.data.user.user_woman
                option.series[0].data[1].value = res.data.user.user_man
                    //重新配置
                myChart.setOption(option);



                //柱状图
                $.each(res.data.all_cate, (i, v) => {

                    option2.xAxis.data.push(v.catename)

                    option2.series[0].data.push(v.num)

                })

                myChart2.setOption(option2);

            }
        })
    }


    //用户统计
    function infoSum(data) {
        $('#admin_num').html(data.admin_num);
        $('#reg_num').html(data.user.total);
        $('#art_num').html(data.article_num);
        $('#adv_num').html(data.advpos_num);
        $('#adv_pic_num').html(data.advimg_num)
    }